/*
 * Ethan Levine
 * 
 * The contents of this file are subject to the GNU General Public
 * License (GPL) v2.  The full contents of this license can be
 * found at Mathma's website, http://www.codeplex.com/mathma/license
 */

package mathma.core.simp;

import mathma.core.expr.Expression;

import mathma.core.value.Value;

import java.util.ArrayList;
import java.util.List;

/**
 * @since 0.1.6
 * @author Ethan Levine
 */
public abstract class BasicSimplifier implements Simplifier {
    
    private List<SimplificationAlgorithm> algs;
    
    protected BasicSimplifier() {
        algs = new ArrayList<SimplificationAlgorithm>();
    }
    
    @Override
    public <T extends Value> Expression<T> simplify(Expression<T> expr) {
        Expression<T> modExpr = expr;
        for (SimplificationAlgorithm alg : algs) {
            modExpr = alg.simplify(modExpr);
        }
        return modExpr;
    }
    
    protected void addAlgorithms(SimplificationAlgorithm... algs) {
        for (SimplificationAlgorithm alg : algs) {
            this.algs.add(alg);
        }
    }
}
